﻿using System;

namespace TweeVo
{
	public static class Twitter
	{
        public static bool VerifyTwitterCredentials(string ConsumerSecret, string Token, string TokenSecret, ref string errormessage)
        {
            oAuthTwitter oAuth = new oAuthTwitter { Token = Token, 
													TokenSecret = TokenSecret, 
													ConsumerSecret = TwitterConst.CONSUMER_SECRET,
													ConsumerKey = TwitterConst.CONSUMER_KEY };

            try
            {
				oAuth.oAuthWebRequest(oAuthTwitter.Method.GET, TwitterConst.VERIFY_URL, String.Empty);
                return true;
            }
            catch (Exception ex)
            {
                errormessage = ex.Message;
                return false;
            }
        }

		public static void PostTwitterUpdate(string tweet)
		{
			Logger.Log("Tweet: " + tweet, LoggerSeverity.Info);

            oAuthTwitter oAuth = new oAuthTwitter { Token = TweeVoSettings.Default.TwitterAuthToken.DecryptString(), 
													TokenSecret = TweeVoSettings.Default.TwitterAuthTokenSecret.DecryptString(), 
													ConsumerSecret = TwitterConst.CONSUMER_SECRET,
													ConsumerKey = TwitterConst.CONSUMER_KEY };

            oAuth.oAuthWebRequest(oAuthTwitter.Method.POST, TwitterConst.UPDATE_URL, "status=" + tweet);
        }
    }
}
